import { user as UserType } from '@prisma/client';
import { Body, Controller, Get, Post, Req } from '@nestjs/common';
import { Request } from 'express';
import { AuthService } from './auth.service';
import { Auth } from './decorator/auth.decorator';
import { User } from './decorator/user.decorator';
import LoginDto from './dto/login.dto';
import RegisterDto from './dto/register.dto';

@Controller('auth')
export class AuthController {
  constructor(private readonly auth: AuthService) {}

  @Post('register')
  register(@Body() dto: RegisterDto) {
    return this.auth.regiter(dto);
  }

  @Post('login')
  login(@Body() dto: LoginDto) {
    return this.auth.login(dto);
  }
  @Get('all')
  @Auth()
  all(@User() user: UserType) {
    return user;
    // return this.auth.findAll();
  }
}
